--DELETE FROM cat_picture
INSERT INTO cat_picture
SELECT
newid() AS [Id],case len(convert(varchar(10),id))
    when 5 then '00000000-0000-0000-0000-0000000' + convert(varchar(10),id) 
    when 4 then '00000000-0000-0000-0000-00000000' + convert(varchar(10),id) 
    when 3 then '00000000-0000-0000-0000-000000000' + convert(varchar(10),id) 
    when 2 then '00000000-0000-0000-0000-0000000000' + convert(varchar(10),id) 
    when 1 then '00000000-0000-0000-0000-00000000000'+ convert(varchar(10),id) 
    end AS [CompanyId],'LOGO' AS [Title],companylogo AS [PictureBinary],NULL AS [ImageUrl],NULL AS [MimeType],NULL AS [Width],NULL AS [Height],NULL AS [Size],NULL AS [SortOrder],1 AS [IsLogo]FROM srv_lnk.nchr2008.dbo.companyInfo
WHERE  NOT companylogo IS NULL AND id in(select id from companyinfo)
